package com.iretailer.report.dto.report;

import lombok.Data;

import java.util.Arrays;
import java.util.List;

/**
 * @Auther: xjw
 * @Date: 2019/1/28 14:05
 * @Description:
 */
@Data
public class ReGroupBy {
    public static final List<String> PERIOD_LIST = Arrays.asList("5m", "15m", "30m", "60m", "1d");
    /**
     * period: 5m,15m,30m,60m,1d,All,"Week"
     */
    private String period;
    /**
     * "All","Mall","PhyId或者是Zone","Tag","Week"
     */
    private String domain;
    /**
     * "yyyy" "yyy-MM" "yyyy-MM-dd" "yyyy-MM-dd HH:mm"
     * "yyyy-MM-dd HH:mm:ss" "HH:mm:ss" "All"(对应period All)
     * "Week"(对应 TimeLabel是星期)
     * 必填 关系到 返回结果集中 TimeLabel 的时间格式
     */
    private String timeFormatter;

    public String getTimeFormatter_() {
        switch (this.timeFormatter) {
            case "All":
                return "yyyy-MM-dd";
            default:
                return this.timeFormatter;
        }
    }

    public int getFlow_periodIndex() {
        switch (this.period) {
            case "Year":
            case "Month":
            case "Week":
            case "Weekday":
            case "All":
                return PERIOD_LIST.indexOf("1d");
            case "Hourly":
                return PERIOD_LIST.indexOf("60m");
            default:
                return PERIOD_LIST.indexOf(this.period);
        }
    }

    public String getFlow_period() {
        switch (this.period) {
            case "Year":
            case "Month":
            case "Week":
            case "Weekday":
            case "All":
                return "1d";
            case "Hourly":
            case "WeekPeak":
            case "MonthPeak":
            case "YearPeak":
                return "60m";
            default:
                return period;
        }
    }


}
